﻿package visualizer.code
{
	import flash.geom.ColorTransform;
	import flash.events.Event;
	import flash.display.MovieClip;
	
	public class DemoVisualizer extends Visualizer
	{
		
		public function DemoVisualizer()
		{
			// Setup Listeners
			addEventListener(Event.ENTER_FRAME,onEnterFrame);
			addEventListener(BeatEvent.LOW_BAND_BEAT, handleLowBeat);
			addEventListener(BeatEvent.MID_BAND_BEAT, handleMidBeat);
			addEventListener(BeatEvent.HIGH_BAND_BEAT, handleHighBeat);
		}
		
		override protected function drawFrame()
		{
			super.drawFrame();
		}
		
		private function onEnterFrame(e:Event)
		{
			
		}
		
		private function handleLowBeat(event:BeatEvent)
		{

		}
		
		private function handleMidBeat(event:BeatEvent)
		{

		}
		
		private function handleHighBeat(event:BeatEvent)
		{

		}
		
		//---------- Convenience Functions ----------//		
		private function random(low:Number=0, high:Number=1):Number
		{
			return Math.floor(Math.random() * (1+high-low)) + low;
		}		
		
		private function gotoAndStopByVol(anim:MovieClip)
		{
			var newFrame:uint = Math.floor((avgVol()*anim.totalFrames)/.9);
			if(newFrame > anim.totalFrames) newFrame = anim.totalFrames;
			anim.gotoAndStop(newFrame);
		}
	}
}